rgba->alpha = color->alpha / 255.;
}
-/* A private structure for keeping width and height. */
+/* A private structure for keeping width, height and scale. */
typedef struct {
int width;
int height;
+ int scale;
} Dimensions;
/* This struct corresponds to a request for an texture.
Dimensions *available_dimensions = data;
int available_width = available_dimensions->width;
int available_height = available_dimensions->height;
+ int scale_factor = available_dimensions->scale;
int scaled_width;
int scaled_height;
&scaled_width, &scaled_height);
gdk_pixbuf_loader_set_size (pixbuf_loader,
- scaled_width,
- scaled_height);
+ scaled_width * scale_factor,
+ scaled_height * scale_factor);
}
static GdkPixbuf *
gsize size,
int available_width,
int available_height,
+ int scale,
GError **error)
{
GdkPixbufLoader *pixbuf_loader = NULL;
available_dimensions.width = available_width;
available_dimensions.height = available_height;
+ available_dimensions.scale = scale;
g_signal_connect (pixbuf_loader, "size-prepared",
G_CALLBACK (on_image_size_prepared), &available_dimensions);
/* We know that the image will later be rotated, so we reverse the available dimensions. */
available_dimensions.width = available_height;
available_dimensions.height = available_width;
+ available_dimensions.scale = scale;
g_signal_connect (pixbuf_loader, "size-prepared",
G_CALLBACK (on_image_size_prepared), &available_dimensions);
impl_load_pixbuf_file (const char *uri,
int available_width,
int available_height,
+ int scale,
GError **error)
{
GdkPixbuf *pixbuf = NULL;
{
pixbuf = impl_load_pixbuf_data ((const guchar *) contents, size,
available_width, available_height,
+ scale,
error);
}
g_assert (data != NULL);
g_assert (data->uri != NULL);
- pixbuf = impl_load_pixbuf_file (data->uri, data->width, data->height, &error);
+ pixbuf = impl_load_pixbuf_file (data->uri, data->width, data->height, 1, &error);
if (error != NULL)
{
const gchar *uri,
int available_width,
int available_height,
+ int scale,
GError **error)
{
CoglHandle texdata;
if (texdata == NULL)
{
- pixbuf = impl_load_pixbuf_file (uri, available_width, available_height, error);
+ pixbuf = impl_load_pixbuf_file (uri, available_width, available_height, scale, error);
if (!pixbuf)
goto out;
const gchar *uri,
int available_width,
int available_height,
+ int scale,
GError **error)
{
cairo_surface_t *surface;
if (surface == NULL)
{
- pixbuf = impl_load_pixbuf_file (uri, available_width, available_height, error);
+ pixbuf = impl_load_pixbuf_file (uri, available_width, available_height, scale, error);
if (!pixbuf)
goto out;
* st_texture_cache_load_file_to_cogl_texture:
* @cache: A #StTextureCache
* @file_path: Path to a file in supported image format
+ * @scale: Scale factor of the display
*
* This function synchronously loads the given file path
* into a COGL texture. On error, a warning is emitted
*/
CoglHandle
st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
- const gchar *file_path)
+ const gchar *file_path,
+ gint scale)
{
CoglHandle texture;
GFile *file;
uri = g_file_get_uri (file);
texture = st_texture_cache_load_uri_sync_to_cogl_texture (cache, ST_TEXTURE_CACHE_POLICY_FOREVER,
- uri, -1, -1, &error);
+ uri, -1, -1, scale, &error);
g_object_unref (file);
g_free (uri);
* st_texture_cache_load_file_to_cairo_surface:
* @cache: A #StTextureCache
* @file_path: Path to a file in supported image format
+ * @scale: Scale factor of the display
*
* This function synchronously loads the given file path
* into a cairo surface. On error, a warning is emitted
*/
cairo_surface_t *
st_texture_cache_load_file_to_cairo_surface (StTextureCache *cache,
- const gchar *file_path)
+ const gchar *file_path,
+ gint scale)
{
cairo_surface_t *surface;
GFile *file;
uri = g_file_get_uri (file);
surface = st_texture_cache_load_uri_sync_to_cairo_surface (cache, ST_TEXTURE_CACHE_POLICY_FOREVER,
- uri, -1, -1, &error);
+ uri, -1, -1, scale, &error);
g_object_unref (file);
g_free (uri);
gdouble background_image_width, background_image_height;
gdouble x, y;
gdouble scale_w, scale_h;
+ int scale_factor;
file = st_theme_node_get_background_image (node);
texture_cache = st_texture_cache_get_default ();
- surface = st_texture_cache_load_file_to_cairo_surface (texture_cache, file);
+ g_object_get (node->context, "scale-factor", &scale_factor, NULL);
+ surface = st_texture_cache_load_file_to_cairo_surface (texture_cache, file, scale_factor);
if (surface == NULL)
return NULL;
const char *filename;
filename = st_border_image_get_filename (border_image);
+
+ int scale_factor;
+ g_object_get (node->context, "scale-factor", &scale_factor, NULL);
+
node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
- filename);
+ filename, scale_factor);
if (node->border_slices_texture == COGL_INVALID_HANDLE)
goto out;
if (background_image == NULL)
goto out;
+ int scale_factor;
+ g_object_get (node->context, "scale-factor", &scale_factor, NULL);
+
background_image_shadow_spec = st_theme_node_get_background_image_shadow (node);
node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
- background_image);
+ background_image, scale_factor);
if (node->background_texture == COGL_INVALID_HANDLE)
goto out;